<#include "/common/_layout.html">
<#assign pageJavascript>
<script type="text/javascript">
var delit = function(obj){
	var tr = $(obj).parent().parent("tr").attr("id");
	var id = tr.replace("tr_","");
	listPage.deleteTr(tr,id);
};
var delitall = function(){
	var ids = "";
	$("#showlist").find("input:checked").each(function(){
		ids += "'"+$(this).val()+"',";
	});
	if(ids.length>0){
		listPage.deleteTrs(ids.substr(0,ids.length-1));
	}
};
$(function(){
	  $(".cheall").click(function () {
	        if ($(".cheall").is(':checked')) {
	           $("tr :checkbox").prop("checked", "checked");
	        }
	        else {
	        	$("tr :checkbox").prop("checked",false);
	        }
	    });
	listPage.config = {listUrl:"/admin/system/client/profile",delUrl:"/admin/system/client/delete"};
	listPage.showlist = function(data){
		if(data.list == undefined) return false;
		$("#showlist").empty();
		$.each(data.list, function (i, row) {
			if(row.sex==1){
				rsex="男";
			}else{
				rsex="女";
			}
			switch(row.medal)
			{
			case 1: medalv = "见习骑士"; break;
			case 2: medalv = "初级骑士"; break;
			case 3: medalv = "中级骑士"; break;
			case 4: medalv = "高级骑士"; break;
			case 5: medalv = "青铜骑士"; break;
			case 6: medalv = "白银骑士"; break;
			case 7: medalv = "黄金骑士"; break;
			case 8: medalv = "白金骑士"; break;
			case 9: medalv = "圣骑士"; break;
			case 10: medalv = "神骑士"; break;
			default:
			case 2: medalv = "您还没有勋章";
			}
			var str = '<tr id="tr_'+row.id+'"><td><input type="checkbox" value="'+row.id+'" class="tr_c" name="tr_'+row.id+'" id="tr_'+row.id+'" /></td><td>'+row.id+'</td><td class="hidden-xs">'+row.username+'</td><td>'+row.birthday+'</td><td>'+rsex+'</td><td>'+row.phone+'</td><td>'+row.address+'</td><td>'+row.jointime+'</td><td>'+row.lasttime+'</td><td  class="hidden-xs">'+medalv+'</td><td>'
			<#if session.usermodels?index_of(",2_2,")&gt;-1 > 
			+'<a class="btn btn-primary btn-xs" href="/admin/system/client/edit/'+row.id+'">修改</a>'
			</#if>
			<#if session.usermodels?index_of(",2_3,")&gt;-1 > 
			+'&nbsp;<button class="btn btn-danger btn-xs" onclick="delit(this)">删除</button>'
			</#if>
			+'</td></tr>';
			$("#showlist").append(str);
		});
		$("#page").page({total:data.totalRow,currentpage:data.pageNumber,gopage:listPage.gopage,pagesize:data.pageSize});
	};
	$("#querybtn").click(function(){
		listPage.gopage(10,1);
	});
	$("#querybtn").click();	
});
</script>
</#assign>
<#assign pageCss>
<style type="text/css">
</style>
</#assign>
<@layout pageTitle="客户个人资料" pageJavascript=pageJavascript pageCss=pageCss>		
<h3 class="page-header">客户个人资料</h3>	
<div class="panel panel-default">
  <div class="panel-body filter">
	<div class="form-inline">
		<div class="form-group">
			<label for="username">客户姓名：</label> 
			<input type="text" class="form-control" id="username" data-rule="like">
			<label>注册时间：</label>
		    <input class="form-control" style="width:160px" onFocus="WdatePicker({readOnly:true,dateFmt:'yyyy-MM-dd HH:mm:ss'})" type="input" data-rule="ge" id="start_jointime" >～
			<input class="form-control" style="width:160px" onFocus="WdatePicker({readOnly:true,dateFmt:'yyyy-MM-dd HH:mm:ss'})" type="input" data-rule="le" id="end_jointime" >
			<label for="rname">客户手机号：</label> 
			<input type="text" class="form-control" id="phone" data-rule="like">
			<label for="rname">勋章等级：</label> 
			<select id="medal" data-rule="eq" class="form-control">
				<option value=" ">所有勋章</option>
	    		<option value="1">见习骑士</option>
	    		<option value="2">初级骑士</option>
	    		<option value="3">中级骑士</option>
	    		<option value="4">高级骑士</option>
	    		<option value="5">青铜骑士</option>
	    		<option value="6">白银骑士</option>
	    		<option value="7">黄金骑士</option>
	    		<option value="8">白金骑士</option>
	    		<option value="9">圣骑士</option>
	    		<option value="10">神骑士</option>
	    	</select>
		</div>
		<button id="querybtn" class="btn btn-default">查询</button>
		<button class="btn btn-danger" onclick="delitall()">批量删除</button>
	</div>
  </div>
</div>
<table class="table table-bordered table-hover table-striped">
	<thead>
		<tr>
		   <th width="50px"><input type="checkbox" name="cheall"
				class="cheall" id="tr_" />全选</th>
			<th width="50px">客户id</th>
			<th width="90px" class="hidden-xs">客户名称</th>
			<th width="30px">生日</th>
			<th width="30px">性别</th>
			<th width="50px">手机号码</th>
			<th width="90px">地址</th>
			<th width="60px">注册时间</th>
			<th width="60px">最后修改时间</th>
			<th width="60px" class="hidden-xs">勋章等级</th>
			<th width="90px">操作</th>
		</tr>
	</thead>
	<tbody id="showlist"></tbody>
</table>
<nav><ul id="page" class="pagination"></ul></nav>
</@layout>